--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tests/backend/test_colour_utils.py e5756d7ab065475a18acdcafc008a767fcff87e0 (e5756d7a) Text, 630 B
T8b949e# SPDX-License-Identifier: 0BSD
Tff7b72import T7ee787pytest
Tff7b72from T7ee787meshchatxT7ee787.T7ee787srcT7ee787.T7ee787backendT7ee787.T7ee787colour_utils Tff7b72import Te6edf3ColourUtils
Tff7b72def Td2a8fftest_hex_colour_to_byte_arrayTb4b4b4(Tb4b4b4)Tb4b4b4:
T8b949e# Test with # prefix
Te6edf3hex_val Tff7b72= Ta5d6ff"Ta5d6ff#FF00AATa5d6ff"
Te6edf3expected Tff7b72= Tffa657bytesTff7b72.Td2a8fffromhexTb4b4b4(Ta5d6ff"Ta5d6ffFF00AATa5d6ff"Tb4b4b4)
Tff7b72assert Te6edf3ColourUtilsTff7b72.Td2a8ffhex_colour_to_byte_arrayTb4b4b4(Te6edf3hex_valTb4b4b4) Tff7b72== Te6edf3expected
T8b949e# Test without # prefix
Te6edf3hex_val Tff7b72= Ta5d6ff"Ta5d6ff00BBFFTa5d6ff"
Te6edf3expected Tff7b72= Tffa657bytesTff7b72.Td2a8fffromhexTb4b4b4(Ta5d6ff"Ta5d6ff00BBFFTa5d6ff"Tb4b4b4)
Tff7b72assert Te6edf3ColourUtilsTff7b72.Td2a8ffhex_colour_to_byte_arrayTb4b4b4(Te6edf3hex_valTb4b4b4) Tff7b72== Te6edf3expected
Tff7b72def Td2a8fftest_hex_colour_to_byte_array_invalidTb4b4b4(Tb4b4b4)Tb4b4b4:
T8b949e# Test with invalid hex
Tff7b72with Te6edf3pytestTff7b72.Td2a8ffraisesTb4b4b4(Tf85149ValueErrorTb4b4b4)Tb4b4b4:
Te6edf3ColourUtilsTff7b72.Td2a8ffhex_colour_to_byte_arrayTb4b4b4(Ta5d6ff"Ta5d6ff#GG00AATa5d6ff"Tb4b4b4)
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────